package com.iscale.model.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.io.Serializable;


/**
 * <p>
 * 区域信息
 * </p>
 *
 * @author Andychen
 * @since 2017-03-08
 */
@SuppressWarnings("serial")
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName("base_region_info")
public class BaseRegionInfo extends Model<BaseRegionInfo> {

    private static final long serialVersionUID = 1L;

	private String id;
    /**
     * 区域名称
     */
	private String name;
    /**
     * 区域全称
     */
	private String fullname;
    /**
     * 上级区域id
     */
	private String pid;
    /**
     * 拼音
     */
	private String pinyin;
    /**
     * 精度
     */
	private String lat;
    /**
     * 维度
     */
	private String lng;
    /**
     * 级别1-省 2-市 3-区 4-街道
     */
	private Integer level;
    /**
     * 区域国家统一编码
     */
	@TableField("cityCode")
	private String cityCode;
	private String description;
    /**
     * 排序
     */
	private Long rank;
    /**
     * 状态 0-可用  1-废弃
     */
	private Integer status;


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public String getPinyin() {
		return pinyin;
	}

	public void setPinyin(String pinyin) {
		this.pinyin = pinyin;
	}

	public String getLat() {
		return lat;
	}

	public void setLat(String lat) {
		this.lat = lat;
	}

	public String getLng() {
		return lng;
	}

	public void setLng(String lng) {
		this.lng = lng;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public String getCityCode() {
		return cityCode;
	}

	public void setCityCode(String cityCode) {
		this.cityCode = cityCode;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getRank() {
		return rank;
	}

	public void setRank(Long rank) {
		this.rank = rank;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Override
	protected Serializable pkVal() {
		return this.id;
	}


	/**
	 * 腾讯 区域 转换成 本地
	 * @param bean
	 * @param level
	 * @return
	 */
	public static BaseRegionInfo QQDistrictToBaseRegion(QQDistrictResult.ResultBean bean,int level){
		BaseRegionInfo  regionInfo = new BaseRegionInfo();
		regionInfo.setId(bean.getId());
		regionInfo.setPid(bean.getPid());
		regionInfo.setLevel(level);
		regionInfo.setName(bean.getName());
		regionInfo.setFullname(bean.getFullname());
		regionInfo.setCityCode(bean.getId());
		if(null!=bean.getLocation()){
			regionInfo.setLng(String.valueOf(bean.getLocation().getLng()));
			regionInfo.setLat(String.valueOf(bean.getLocation().getLat()));
		}
		if(null!=bean.getPinyin() && bean.getPinyin().size()>0){
			String pins = "";
			for(String pin:bean.getPinyin()){
				pins += pin;
			}
			regionInfo.setPinyin(pins);
		}
		regionInfo.setDescription(bean.getFullname());

		return regionInfo;
	}

}
